import java.util.*;
public class Main2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int c = in.nextInt();
        int[] a =new int[1000000];
        int e;
        int max=0;
        for(int i=0;i<c;i++){
            e=in.nextInt();
            a[e]++;
            if(a[e]>max){
                max=a[e];
            }
        }
        int m =c-max;
        System.out.println(m);
    }
}